Skip to content

Refactor semantic id handler to saperate the logic#78

Merged
mm-hsh merged 21 commits intodevelopfrom
feature/128-refactor-semantic-id-handler-saperate
Mar 24, 2026
Merged

Refactor semantic id handler to saperate the logic#78
mm-hsh merged 21 commits intodevelopfrom
feature/128-refactor-semantic-id-handler-saperate

Conversation

@mm-kgi
Copy link
Copy Markdown
Contributor

@mm-kgi mm-kgi commented Mar 18, 2026

Restructured the SemanticId handling logic by introducing dedicated handlers for each submodel element, reducing complexity and improving readability.

Copilot AI review requested due to automatic review settings March 18, 2026 18:52
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 18, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors SemanticIdHandler into a small facade delegating to a semantic tree extractor and a submodel filler, with per–submodel-element-type handlers and shared helper utilities, to reduce complexity and improve maintainability of semantic-id extraction/fill-out logic.

Changes:

  • Introduced SemanticId subsystem (Extraction, FillOut, ElementHandlers, Helpers) and rewired DI to register these services/handlers.
  • Replaced the monolithic SemanticIdHandler implementation with delegation to ISemanticTreeExtractor + ISubmodelFiller.
  • Added/updated unit tests for helpers, extractor/filler, and element handlers; adjusted existing tests accordingly.

Reviewed changes

Copilot reviewed 45 out of 46 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
source/AAS.TwinEngine.DataEngine/ServiceConfiguration/ApplicationDependencyInjectionExtensions.cs Registers new semantic-id services/helpers/handlers in DI.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SubmodelRepositoryService.cs Minor refactor around template fill-out call (plus new import).
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandler.cs Replaces monolithic logic with extractor+filler delegation.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelper.cs Adds submodel element cloning/path navigation/language resolution helper.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigator.cs Centralizes semantic-tree traversal utilities.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolver.cs Centralizes semantic-id/cardinality/value-type resolution logic.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelper.cs Extracts/populates model reference keys via semantic tree nodes.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISubmodelElementHelper.cs Interface for element helper functions.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISemanticIdResolver.cs Interface for semantic id resolver.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/IReferenceHelper.cs Interface for reference helper behavior.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFiller.cs New fill-out engine that delegates element fill-out to type handlers.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/ISubmodelFiller.cs Interface for submodel filling.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractor.cs New extractor that delegates element extraction to type handlers.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/ISemanticTreeExtractor.cs Interface for semantic tree extraction.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandler.cs Handles relationship element extraction/fill-out via reference helper.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandler.cs Handles reference element extraction/fill-out via reference helper.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandler.cs Handles range extraction/fill-out (min/max leaves).
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandler.cs Handles property extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandler.cs Handles MLP extraction/fill-out with language resolution.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandler.cs Handles submodel element list extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ISubmodelElementTypeHandler.cs Defines element handler contract (extract + fill-out).
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandler.cs Handles file extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandler.cs Handles entity extraction/fill-out (incl. self-managed fields).
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandler.cs Handles collection extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandler.cs Handles blob extraction/fill-out (base64 decode).
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/AasRegistry/ShellDescriptorService.cs Minor catch-block cleanup.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/TestData.cs Adjusts shared test data (specific asset ids naming/init).
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandlerTests.cs Updates tests to use new extractor/filler architecture.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelperTests.cs Adds unit tests for SubmodelElementHelper.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigatorTests.cs Adds unit tests for semantic-tree navigation helpers.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolverTests.cs Adds unit tests for semantic id resolver behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelperTests.cs Adds unit tests for reference extraction/population.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFillerTests.cs Adds unit tests for submodel filler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractorTests.cs Adds unit tests for semantic tree extractor behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandlerTests.cs Adds unit tests for relationship handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandlerTests.cs Adds unit tests for reference handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandlerTests.cs Adds unit tests for range handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandlerTests.cs Adds unit tests for property handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandlerTests.cs Adds unit tests for MLP handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandlerTests.cs Adds unit tests for list handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandlerTests.cs Adds unit tests for file handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandlerTests.cs Adds unit tests for entity handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandlerTests.cs Adds unit tests for collection handler behavior.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandlerTests.cs Adds unit tests for blob handler behavior.
source/AAS.TwinEngine.DataEngine.ModuleTests/Api/Services/SubmodelRepository/SubmodelRepositoryControllerTests.cs Minor test cleanup (discarding return values).
example/docker-compose.yml Changes DataEngine image reference used by the example stack.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@mm-hsh mm-hsh requested a review from Copilot March 19, 2026 07:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors SemanticId handling by splitting the previously monolithic SemanticIdHandler into focused components (resolver/helpers, per-element handlers, extractor, and filler), and wires the new services through dependency injection with corresponding unit/module test updates.

Changes:

  • Introduced dedicated ISubmodelElementTypeHandler implementations plus new helper/resolver utilities to handle extraction and fill-out logic per submodel element type.
  • Replaced SemanticIdHandler’s internal logic with delegation to ISemanticTreeExtractor and ISubmodelFiller.
  • Updated DI registrations and extended/adjusted unit + module tests to cover the refactor.

Reviewed changes

Copilot reviewed 45 out of 45 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
source/AAS.TwinEngine.DataEngine/ServiceConfiguration/ApplicationDependencyInjectionExtensions.cs Registers new SemanticId extractor/filler/helpers and element handlers in DI.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SubmodelRepositoryService.cs Minor refactor around returning filled submodel.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandler.cs Delegates semantic-id operations to extractor/filler.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelper.cs Adds cloning, idShort navigation, and language resolution utilities.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigator.cs Centralizes semantic tree traversal helpers.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolver.cs Centralizes semantic-id resolution, cardinality, and datatype inference.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelper.cs Extracts/populates reference keys and relationship references.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISubmodelElementHelper.cs Interface for submodel element helper utilities.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/ISemanticIdResolver.cs Interface for semantic-id resolution operations.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/Interfaces/IReferenceHelper.cs Interface for reference extraction/population logic.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFiller.cs Implements template fill-out using element handlers.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/ISubmodelFiller.cs Interface for submodel fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractor.cs Implements semantic tree extraction using element handlers.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/ISemanticTreeExtractor.cs Interface for semantic tree extraction.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandler.cs Handler for relationship element extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandler.cs Handler for reference element extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandler.cs Handler for range extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandler.cs Handler for property extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandler.cs Handler for multi-language property extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandler.cs Handler for submodel element list extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ISubmodelElementTypeHandler.cs Defines the handler contract for element types.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandler.cs Handler for file extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandler.cs Handler for entity extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandler.cs Handler for collection extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandler.cs Handler for blob extraction/fill-out.
source/AAS.TwinEngine.DataEngine/ApplicationLogic/Services/AasRegistry/ShellDescriptorService.cs Removes unused exception variable in catch block.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/TestData.cs Updates shared test data for entity specific asset ids.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticIdHandlerTests.cs Updates SemanticIdHandler tests to use new components/handlers.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SubmodelElementHelperTests.cs Adds unit tests for SubmodelElementHelper.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticTreeNavigatorTests.cs Adds unit tests for SemanticTreeNavigator.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/SemanticIdResolverTests.cs Adds unit tests for SemanticIdResolver.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Helpers/ReferenceHelperTests.cs Adds unit tests for ReferenceHelper.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/FillOut/SubmodelFillerTests.cs Adds unit tests for SubmodelFiller.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/Extraction/SemanticTreeExtractorTests.cs Adds unit tests for SemanticTreeExtractor.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RelationshipElementHandlerTests.cs Adds unit tests for RelationshipElementHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ReferenceElementHandlerTests.cs Adds unit tests for ReferenceElementHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/RangeHandlerTests.cs Adds unit tests for RangeHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/PropertyHandlerTests.cs Adds unit tests for PropertyHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/MultiLanguagePropertyHandlerTests.cs Adds unit tests for MultiLanguagePropertyHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/ListHandlerTests.cs Adds unit tests for ListHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/FileHandlerTests.cs Adds unit tests for FileHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/EntityHandlerTests.cs Adds unit tests for EntityHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/CollectionHandlerTests.cs Adds unit tests for CollectionHandler.
source/AAS.TwinEngine.DataEngine.UnitTests/ApplicationLogic/Services/SubmodelRepository/SemanticId/ElementHandlers/BlobHandlerTests.cs Adds unit tests for BlobHandler.
source/AAS.TwinEngine.DataEngine.ModuleTests/Api/Services/SubmodelRepository/SubmodelRepositoryControllerTests.cs Minor test adjustments to discard unused return values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@mm-kgi mm-kgi requested a review from mm-asha March 19, 2026 08:08
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown

Test & Coverage Report

Test Results Summary

Metric Count
✅ Passed 1020
❌ Failed 0
⏭️ Skipped 0

View Detailed Test Results


Code Coverage

Unit Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 91% 83% 1507
Summary 91% (2560 / 2811) 83% (1075 / 1299) 1507

Minimum allowed line rate is 80%

Module Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 55% 42% 1507
Summary 55% (1559 / 2811) 42% (540 / 1299) 1507

@mm-hsh mm-hsh merged commit a565073 into develop Mar 24, 2026
10 checks passed
@mm-hsh mm-hsh deleted the feature/128-refactor-semantic-id-handler-saperate branch March 25, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants